import { createApp } from "vue";
import router from "./router";
import App from "./App.vue";
import { createPinia } from "pinia";
import piniaPluginPersist from "pinia-plugin-persist"; // pinia持久化插件
import NProgress from "nprogress";
import "nprogress/nprogress.css";
import "./style.scss";
const app = createApp(App);
// 状态管理器
const pinia = createPinia();
pinia.use(piniaPluginPersist);
/**
 * 显示消息
 */

// element 图标引入
import * as ElementPlusIconsVue from "@element-plus/icons-vue";
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// 路由开始时
router.beforeEach((_to, _from, next) => {
  NProgress.start();
  next();
});

// 路由结束时
router.afterEach(() => {
  NProgress.done();
});

app.use(pinia);
app.use(router);
app.mount("#app");
